import Vue from 'vue'
import Router from 'vue-router'
import home from '@/pages/home'
import query from '@/pages/query'
import user from '@/pages/user'
import supply from '@/pages/supply'
import supplyAdd from '@/pages/supplyAdd'
import bind from '@/pages/bind'
import bindSuccess from '@/pages/bindSuccess'
import shopcart from '@/pages/shopcart'
import orderBuy from '@/pages/orderBuy'
import supplyList from '@/pages/supplyList'
import complain from '@/pages/complain'
import mylist from '@/pages/mylist'
import detail from '@/pages/detail'
import detailPic from '@/pages/detailPic'
import demandAdd from '@/pages/demandAdd'
import baojia from '@/pages/baojia'
import supplyBJ from '@/pages/supplyBJ'
import ent from '@/pages/ent'
import test from '@/pages/test'
import pub from '@/pages/pub'
import msg from '@/pages/msg'
import msgUserList from '@/pages/msgUserList'
import demand from '@/pages/demand'
import batchMatch from '@/pages/batchMatch'
import viewPic from '@/pages/viewPic'
import link from '@/pages/link'
import detail2 from '@/pages/detail2'
import entList from '@/pages/entList'
import batchTJ from '@/pages/batchTJ'

Vue.use(Router)

export default new Router({
  // mode: 'history',  //这里
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop
      }
      return { x: 0, y: to.meta.savedPosition || 0 }
    }
  },
  routes: [
    {
      path: '/',
      name: '首页',
      component: home,
      // meta: {
      //   keepAlive: true, //此组件需要被缓存

      // }
    },
    {
      path: '/m1',
      name: '首页',
      component: home
    },
    {
      path: '/m2',
      name: '首页',
      component: home
    },
    {
      path: '/m3',
      name: '首页',
      component: home
    },
    {
      path: '/home',
      name: '首页',
      component: home,
      // meta: {
      //   keepAlive: true, //此组件需要被缓存

      // }
    },
    {
      path: '/query',
      name: '批号查询',
      component: query
    },
    {
      path: '/TeJia',
      name: '特价推荐资源',
      component: batchTJ
    },
    {
      path: '/user',
      name: '用户中心',
      component: user
    },
    {
      path: '/supply',
      name: '定制需求',
      component: supply,
      meta: {
        keepAlive: true, //此组件需要被缓存

      }
    },
    {
      path: '/demand',
      name: '定制需求',
      component: demand
    },
    {
      path: '/user/supplyAdd',
      name: '定制需求',
      component: supplyAdd
    },
    {
      path: '/user/demandAdd',
      name: '定制需求',
      component: demandAdd
    },
    {
      path: '/user/batchMatch/:id',
      name: '定制需求查看',
      component: batchMatch
    },
    {
      path: '/user/bind',
      name: '绑定手机',
      component: bind
    },
    {
      path: '/user/bindSuccess',
      name: '注册成功',
      component: bindSuccess
    },
    {
      path: '/user/shopcart',
      name: '购物车',
      component: shopcart
    },
    {
      path: '/user/link',
      name: '分享链接',
      component: link
    },
    {
      path: '/orderBuy',
      name: '买家订单',
      component: orderBuy
    },
    {
      path: '/supplyList',
      name: '需求对接',
      component: supplyList
    },
    {
      path: '/user/supplyBJ',
      name: '报价',
      component: supplyBJ
    },
    {
      path: '/user/complain',
      name: '意见投诉',
      component: complain
    },
    {
      path: '/user/entList',
      name: '企业名录',
      component: entList
    },
    {
      path: '/mylist',
      name: '我的列表',
      component: mylist
    },
    {
      path: '/detail/:id',
      name: '资源详情',
      component: detail
    },
    {
      path: '/detailPic/:id',
      name: '资源详情',
      component: detailPic
    },
    {
      path: '/baojia/:id',
      name: '供需详情',
      component: baojia
    },
    {
      path: '/ent',
      name: '企业名片',
      component: ent
    }
    ,
    {
      path: '/test',
      name: '测试',
      component: test
    },
    {
      path: '/user/pub',
      name: '资源发布',
      component: pub
    },
    {
      path: '/pub',
      name: '资源发布',
      component: pub
    },
    {
      path: '/query/detail',
      name: '批号查询',
      component: detail2
    },
    {
      path: '/user/msg',
      name: '我的私信',
      component: msg
    },
    {
      path: '/user/msgUserList',
      name: '我的私信',
      component: msgUserList
    },
    {
      path: '/user/viewPic',
      name: '生成图片',
      component: viewPic
    },
  ]
})
